package fr.afcepf.iziticket.beans;

import javax.faces.application.NavigationHandler;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import fr.afcepf.iziticket.entities.Commande;
import fr.afcepf.iziticket.services.DetailCommandeService;

@ManagedBean(name="mbDetailCommande")
@SessionScoped
public class DetailCommandeManagedBean {

	private DetailCommandeService service = DetailCommandeService.getService();
	
	private Commande commande;

	public Commande getCommande() {
		return commande;
	}
	public void setCommande(Commande commande) {
		this.commande = commande;
	}
	
	public void voirDetail(ActionEvent ae){
		int idCommande = Integer.parseInt(ae.getComponent().getAttributes().get("idCommande").toString());
		
		this.commande = service.voirDetail(idCommande);
		
		FacesContext facesContext = FacesContext.getCurrentInstance();
		NavigationHandler myNav = facesContext.getApplication().getNavigationHandler();
	    myNav.handleNavigation(facesContext, null, "/detailCommande.xhtml");
	}
	
	public void imprimer(ActionEvent ae){
	}

}
